<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ruoyi/css/ry-ui.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/datapicker/datepicker3.css}" rel="stylesheet"/>
<link th:href="@{/css/meals.css}" rel="stylesheet"/>
<style>
    .droppable-active{background-color:#ffe!important}.tools a{cursor:pointer;font-size:80%}.form-body .col-md-6,.form-body .col-md-12{min-height:400px}.draggable{cursor:move}
</style>

<body class="gray-bg">
<div class="container">
    <div class="row">
        <form class="form-horizontal m" id="form-meals-setting" th:object="${settings}">
            <input id="mealsId" name="mealsId" th:field="${settings.mealsId}"  type="hidden">
            <div class="col-md-12 content01">
                <div class="form-group">
                    <label class="col-sm-3 control-label">报餐日期</label>
                    <div class="col-sm-9">
                        <div class="radio-box" th:each="dict : ${@dict.getType('meals_date')}">
                            <input type="radio" th:id="${dict.dictCode}" name="mealsDate" th:value="${dict.dictValue}" th:field="${settings.mealsDate}">
                            <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">报餐时间</label>
                    <label class="col-sm-3 label2">在就餐前</label>
                    <div class="col-sm-9">
                        <select id="mealsTime" class="form-control m-b" th:with="type=${@dict.getType('meals_time')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="${settings.mealsTime}"></option>
                        </select>
                    </div>
                    <label class="col-sm-3 control-label2">小时截止报餐</label>
                </div>
            </div>
            <!--=====================-->
            <div class="content02">
                <label class="col-sm-3 control-label">餐别设置</label>
                <div class="main">
                    <div class="breakfast">
                        <div class="left">
                            <div class="col-sm-9 of">
                                <div class="onoffswitch">
                                    <input type="checkbox" th:checked="${settings.isBreakfast == '0' ? true : false}" class="onoffswitch-checkbox" id="isBreakfast" name="isBreakfast">
                                    <label class="onoffswitch-label" for="isBreakfast">
                                        <span class="onoffswitch-inner"></span>
                                        <span class="onoffswitch-switch"></span>
                                    </label>
                                </div>
                            </div>
                            <label class="col-sm-3 label2">早餐</label>
                        </div>

                        <div class="center">
                            <label class="col-sm-3 control-label">开始时间</label>
                            <div class="col-sm-9">
                                <select id="breakfastStart" class="form-control m-b" th:with="type=${@dict.getType('meals_type_time')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}" th:field="${settings.breakfastStart}"></option>
                                </select>
                            </div>
                        </div>

                        <div class="right">
                            <label class="col-sm-3 control-label">结束时间</label>
                            <div class="col-sm-9">
                                <select id="breakfastEnd" class="form-control m-b" th:with="type=${@dict.getType('meals_type_time')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}" th:field="${settings.breakfastEnd}"></option>
                                </select>
                            </div>
                        </div>

                    </div>

                    <div class="lunch">
                        <div class="left">
                            <div class="col-sm-9 of">
                                <div class="onoffswitch">
                                    <input type="checkbox" th:checked="${settings.isLunch == '0' ? true : false}" class="onoffswitch-checkbox" id="isLunch" name="isLunch">
                                    <label class="onoffswitch-label" for="isLunch">
                                        <span class="onoffswitch-inner"></span>
                                        <span class="onoffswitch-switch"></span>
                                    </label>
                                </div>
                            </div>
                            <label class="col-sm-3 label2">午餐</label>
                        </div>

                        <div class="center">
                            <label class="col-sm-3 control-label">开始时间</label>
                            <div class="col-sm-9">
                                <select id="lunchStart" class="form-control m-b" th:with="type=${@dict.getType('meals_type_time')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}" th:field="${settings.lunchStart}"></option>
                                </select>
                            </div>
                        </div>

                        <div class="right">
                            <label class="col-sm-3 control-label">结束时间</label>
                            <div class="col-sm-9">
                                <select id="lunchEnd" class="form-control m-b" th:with="type=${@dict.getType('meals_type_time')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}" th:field="${settings.lunchEnd}"></option>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="dinner">
                        <div class="left">
                            <div class="col-sm-9 of">
                                <div class="onoffswitch">
                                    <input type="checkbox" th:checked="${settings.isDinner == '0' ? true : false}" class="onoffswitch-checkbox" id="isDinner" name="isDinner">
                                    <label class="onoffswitch-label" for="isDinner">
                                        <span class="onoffswitch-inner"></span>
                                        <span class="onoffswitch-switch"></span>
                                    </label>
                                </div>
                            </div>
                            <label class="col-sm-3 label2">晚餐</label>
                        </div>

                        <div class="center">
                            <label class="col-sm-3 control-label">开始时间</label>
                            <div class="col-sm-9">
                                <select id="dinnerStart" class="form-control m-b" th:with="type=${@dict.getType('meals_type_time')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}" th:field="${settings.dinnerStart}"></option>
                                </select>
                            </div>
                        </div>

                        <div class="right">
                            <label class="col-sm-3 control-label">结束时间</label>
                            <div class="col-sm-9">
                                <select id="dinnerEnd" class="form-control m-b" th:with="type=${@dict.getType('meals_type_time')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}" th:field="${settings.dinnerEnd}"></option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="other">
                        <div class="left">
                            <div class="col-sm-9 of">
                                <div class="onoffswitch">
                                    <input type="checkbox" th:checked="${settings.isOther == '0' ? true : false}" class="onoffswitch-checkbox" id="isOther" name="isOther">
                                    <label class="onoffswitch-label" for="isOther">
                                        <span class="onoffswitch-inner"></span>
                                        <span class="onoffswitch-switch"></span>
                                    </label>
                                </div>
                            </div>
                            <label class="col-sm-3 label2">其他餐</label>
                        </div>

                        <div class="center">
                            <label class="col-sm-3 control-label">开始时间</label>
                            <div class="col-sm-9">
                                <select id="otherStart" class="form-control m-b" th:with="type=${@dict.getType('meals_type_time')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}" th:field="${settings.otherStart}"></option>
                                </select>
                            </div>
                        </div>

                        <div class="right">
                            <label class="col-sm-3 control-label">结束时间</label>
                            <div class="col-sm-9">
                                <select id="otherEnd" class="form-control m-b" th:with="type=${@dict.getType('meals_type_time')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}" th:field="${settings.otherEnd}"></option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="content02">
                <label class="col-sm-3 control-label">报餐方式</label>
                <div class="main">
                    <div class="content02 content03">
                        <label class="col-sm-3 control-label">早餐</label>
                        <div class="center breakfastType constom-radio">
                            <div class="radio-box" th:each="dict : ${@dict.getType('meals_type')}">
                                <input type="radio" class="breakfastType" id="breakfastType" name="breakfastType" th:value="${dict.dictValue}" th:field="${settings.breakfastType}">
                                <label for="breakfastType" th:text="${dict.dictLabel}"></label>
                            </div>
                        </div>
                    </div>
                    <div class="content02 check-wrapper check-wrapper-b display-hide">
                        <!--<label class="col-sm-3 control-label"></label>-->
                        <div class="check-wrapper-box">
                            <div class="radio-box">
                                <input type="radio" name="breakfastType1" value="0" th:attr="checked=${settings.breakfastType1 eq null || settings.breakfastType1 eq '' || settings.breakfastType1 eq '0' ?true:false}">
                                <label>不计费</label>
                            </div>
                            <div class="radio-box">
                                <input type="radio" name="breakfastType1" value="" th:attr="checked=${settings.breakfastType1 eq '0'  || settings.breakfastType1 eq '' || settings.breakfastType1 eq null?false:true}">
                                <label class="center-flex">固定费用：</label>
                            </div>
                            <div class="center-flex" style="justify-content: center; align-items: center;">
                                <input type="number" name="breakfastType1" id="breakfast-type1" th:value="${settings.breakfastType1}" class="form-control" th:if="${settings.breakfastType1 eq '0'?false:true}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <input type="number" name="breakfastType1" id="breakfast-type1" class="form-control" th:if="${settings.breakfastType1 eq '0'?true:false}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <span style="margin-left: 5px;margin-right: 15px;">/元份</span>
                            </div>
                        </div>
                    </div>
                    <div class="content02 check-wrapper check-wrapper-b display-hide">
                        <!--<label class="col-sm-3 control-label"></label>-->
                        <div class="check-wrapper-box check-wrapper-box2">
                            <div class="radio-box">
                                <input type="radio" value="0" name="breakfastType2" th:attr="checked=${settings.breakfastType2 eq null || settings.breakfastType2 eq '' || settings.breakfastType2 eq '0' ?true:false}">
                                <label>不计费</label>
                            </div>
                            <div class="radio-box">
                                <input type="radio" name="breakfastType2" value="" th:attr="checked=${settings.breakfastType2 eq '0' || settings.breakfastType2 eq '-1' || settings.breakfastType2 eq '' || settings.breakfastType2 eq null?false:true}">
                                <label class="center-flex">固定费用：</label>
                            </div>
                            <div class="center-flex" style="justify-content: center; align-items: center;">
                                <input type="number" name="breakfastType2" id="breakfast-type2" th:value="${settings.breakfastType2}" class="form-control" th:if="${settings.breakfastType2 eq '0' || settings.breakfastType2 eq '-1'?false:true}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <input type="number" name="breakfastType2" id="breakfast-type2" class="form-control" th:if="${settings.breakfastType2 eq '0' || settings.breakfastType2 eq '-1'?true:false}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <span style="margin-left: 5px;margin-right: 15px;">/元份</span>
                            </div>
                            <div class="radio-box sum-price-radio">
                                <input type="radio" value="-1" th:field="${settings.breakfastType2}">
                                <label>累加预订菜品单价</label>
                            </div>
                        </div>
                    </div>

                    <div class="content02 content03">
                        <label class="col-sm-3 control-label">午餐</label>
                        <div class="center">
                            <div class="radio-box" th:each="dict : ${@dict.getType('meals_type')}">
                                <input type="radio" id="lunchType" name="lunchType" th:value="${dict.dictValue}" th:field="${settings.lunchType}">
                                <label for="lunchType" th:text="${dict.dictLabel}"></label>
                            </div>
                        </div>
                    </div>
                    <div class="content02 check-wrapper check-wrapper-l display-hide">
                        <!--<label class="col-sm-3 control-label"></label>-->
                        <div class="check-wrapper-box">
                            <div class="radio-box">
                                <input type="radio" name="lunchType1" value="0" th:attr="checked=${settings.lunchType1 eq null || settings.lunchType1 eq '' || settings.lunchType1 eq '0' ?true:false}">
                                <label>不计费</label>
                            </div>
                            <div class="radio-box">
                                <input type="radio" name="lunchType1" value="" th:attr="checked=${settings.lunchType1 eq '0'  || settings.lunchType1 eq '' || settings.lunchType1 eq null?false:true}">
                                <label class="center-flex">固定费用：</label>
                            </div>
                            <div class="center-flex" style="justify-content: center; align-items: center;">
                                <input type="number" name="lunchType1" id="lunch-type1" th:value="${settings.lunchType1}" class="form-control" th:if="${settings.lunchType1 eq '0'?false:true}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <input type="number" name="lunchType1" id="lunch-type1" class="form-control" th:if="${settings.lunchType1 eq '0'?true:false}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <span style="margin-left: 5px;margin-right: 15px;">/元份</span>
                            </div>
                        </div>
                    </div>
                    <div class="content02 check-wrapper check-wrapper-l display-hide">
                        <div class="check-wrapper-box check-wrapper-box2">
                            <div class="radio-box">
                                <input type="radio" value="0" name="lunchType2" th:attr="checked=${settings.lunchType2 eq null || settings.lunchType2 eq '' || settings.lunchType2 eq '0' ?true:false}">
                                <label>不计费</label>
                            </div>
                            <div class="radio-box">
                                <input type="radio" name="lunchType2" value="" th:attr="checked=${settings.dinnerType2 eq '0' || settings.dinnerType2 eq '-1' || settings.lunchType2 eq '' || settings.lunchType2 eq null?false:true}">
                                <label class="center-flex">固定费用：</label>
                            </div>
                            <div class="center-flex" style="justify-content: center; align-items: center;">
                                <input type="number" name="lunchType2" id="lunch-type2" th:value="${settings.lunchType2}" class="form-control" th:if="${settings.lunchType2 eq '0' || settings.lunchType2 eq '-1'?false:true}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <input type="number" name="lunchType2" id="lunch-type2" class="form-control" th:if="${settings.lunchType2 eq '0' || settings.lunchType2 eq '-1'?true:false}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <span style="margin-left: 5px;margin-right: 15px;">/元份</span>
                            </div>
                            <div class="radio-box sum-price-radio">
                                <input type="radio" value="-1" th:field="${settings.lunchType2}">
                                <label>累加预订菜品单价</label>
                            </div>
                        </div>
                    </div>

                    <div class="content02 content03">
                        <label class="col-sm-3 control-label">晚餐</label>
                        <div class="center">
                            <div class="radio-box" th:each="dict : ${@dict.getType('meals_type')}">
                                <input type="radio" id="dinnerType" name="dinnerType" th:value="${dict.dictValue}" th:field="${settings.dinnerType}">
                                <label for="dinnerType" th:text="${dict.dictLabel}"></label>
                            </div>
                        </div>
                    </div>
                    <div class="content02 check-wrapper check-wrapper-d display-hide">
                        <!--<label class="col-sm-3 control-label"></label>-->
                        <div class="check-wrapper-box">
                            <div class="radio-box">
                                <input type="radio" name="dinnerType1" value="0" th:attr="checked=${settings.dinnerType1 eq null || settings.dinnerType1 eq '' || settings.dinnerType1 eq '0' ?true:false}">
                                <label>不计费</label>
                            </div>
                            <div class="radio-box">
                                <input type="radio" name="dinnerType1" value="" th:attr="checked=${settings.dinnerType1 eq '0'  || settings.dinnerType1 eq '' || settings.dinnerType1 eq null?false:true}">
                                <label class="center-flex">固定费用：</label>
                            </div>
                            <div class="center-flex" style="justify-content: center; align-items: center;">
                                <input type="number" name="dinnerType1" id="dinner-type1" th:value="${settings.dinnerType1}" class="form-control" th:if="${settings.dinnerType1 eq '0'?false:true}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <input type="number" name="dinnerType1" id="dinner-type1" class="form-control" th:if="${settings.dinnerType1 eq '0'?true:false}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <span style="margin-left: 5px;margin-right: 15px;">/元份</span>
                            </div>
                        </div>
                    </div>
                    <div class="content02 check-wrapper check-wrapper-d display-hide">
                        <!--<label class="col-sm-3 control-label"></label>-->
                        <div class="check-wrapper-box check-wrapper-box2">
                            <div class="radio-box">
                                <input type="radio" value="0" name="dinnerType2" th:attr="checked=${settings.dinnerType2 eq null || settings.dinnerType2 eq '' || settings.dinnerType2 eq '0' ?true:false}">
                                <label>不计费</label>
                            </div>
                            <div class="radio-box">
                                <input type="radio" value="" th:attr="checked=${settings.dinnerType2 eq '0' || settings.dinnerType2 eq '-1' || settings.dinnerType2 eq '' || settings.dinnerType2 eq null?false:true}" name="dinnerType2">
                                <label class="center-flex">固定费用：</label>
                            </div>
                            <div class="center-flex" style="justify-content: center; align-items: center;">
                                <input type="number" name="dinnerType2" id="dinner-type2" th:value="${settings.dinnerType2}" class="form-control" th:if="${settings.dinnerType2 eq '0' || settings.dinnerType2 eq '-1'?false:true}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <input type="number" name="dinnerType2" id="dinner-type2" class="form-control" th:if="${settings.dinnerType2 eq '0' || settings.dinnerType2 eq '-1'?true:false}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <span style="margin-left: 5px;margin-right: 15px;">/元份</span>
                            </div>
                            <div class="radio-box sum-price-radio">
                                <input type="radio" value="-1" th:field="${settings.dinnerType2}">
                                <label>累加预订菜品单价</label>
                            </div>
                        </div>
                    </div>

                    <div class="content02 content03">
                        <label class="col-sm-3 control-label">其他餐</label>
                        <div class="center">
                            <div class="radio-box" th:each="dict : ${@dict.getType('meals_type')}">
                                <input type="radio" th:id="otherType" name="otherType" th:value="${dict.dictValue}" th:field="${settings.otherType}">
                                <label th:for="otherType" th:text="${dict.dictLabel}"></label>
                            </div>
                        </div>
                    </div>
                    <div class="content02 check-wrapper check-wrapper-o display-hide">
                        <div class="check-wrapper-box">
                            <div class="radio-box">
                                <input type="radio" name="otherType1" value="0" th:attr="checked=${settings.otherType1 eq null || settings.otherType1 eq '' || settings.otherType1 eq '0' ?true:false}">
                                <label>不计费</label>
                            </div>
                            <div class="radio-box">
                                <input type="radio" name="otherType1" value="" th:attr="checked=${settings.otherType1 eq '0'  || settings.otherType1 eq '' || settings.otherType1 eq null?false:true}">
                                <label class="center-flex">固定费用：</label>
                            </div>
                            <div class="center-flex" style="justify-content: center; align-items: center;">
                                <input type="number" name="otherType1" id="other-type1" th:value="${settings.otherType1}" class="form-control other-type1" th:if="${settings.otherType1 eq '0'?false:true}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <input type="number" name="otherType1" id="other-type1"  class="form-control other-type1" th:if="${settings.otherType1 eq '0'?true:false}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <span style="margin-left: 5px;margin-right: 15px;">/元份</span>
                            </div>
                        </div>
                    </div>
                    <div class="content02 check-wrapper check-wrapper-o display-hide">
                        <!--<label class="col-sm-3 control-label"></label>-->
                        <div class="check-wrapper-box check-wrapper-box2">
                            <div class="radio-box">
                                <input type="radio" value="0" name="otherType2" th:attr="checked=${settings.otherType2 eq null || settings.otherType2 eq '' || settings.otherType2 eq '0' ?true:false}">
                                <label>不计费</label>
                            </div>
                            <div class="radio-box">
                                <input type="radio" name="otherType2" value="" th:attr="checked=${settings.otherType2 eq '0' || settings.otherType2 eq '-1' || settings.otherType2 eq '' || settings.otherType2 eq null?false:true}">
                                <label class="center-flex">固定费用：</label>
                            </div>
                            <div class="center-flex" style="justify-content: center; align-items: center;">
                                <input type="number" name="otherType2" id="other-type2" th:value="${settings.otherType2}" class="form-control other-type2" th:if="${settings.otherType2 eq '0' || settings.otherType2 eq '-1'?false:true}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <input type="number" name="otherType2" id="other-type2" class="form-control other-type2" th:if="${settings.otherType2 eq '0' || settings.otherType2 eq '-1'?true:false}" style="width: 90px;height: 28px;border-radius: 4px;border: 1px solid #aaa;">
                                <span style="margin-left: 5px;margin-right: 15px;">/元份</span>
                            </div>
                            <div class="radio-box sum-price-radio">
                                <input type="radio" value="-1" th:field="${settings.otherType2}">
                                <label>累加预订菜品单价</label>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <div class="line"></div>
            <div class="content04">
                <div class="top">
                    <label class="col-sm-3 control-label" for="-NaN">菜品图片</label>
                    <div class="col-sm-9 of">
                        <div class="onoffswitch">
                            <input type="checkbox" th:checked="${settings.isDishPic == '0' ? true : false}" class="onoffswitch-checkbox" id="isDishPic" name="isDishPic">
                            <label class="onoffswitch-label" for="isDishPic">
                                <span class="onoffswitch-inner"></span>
                                <span class="onoffswitch-switch"></span>
                            </label>
                        </div>
                    </div>
                    <label class="tips2" >显示菜品图片</label>
                </div>
                <div class="top">
                    <div>
                        <label class="col-sm-3 control-label">扫码签到</label>
                        <div class="col-sm-9">
                            <div class="radio-box">
                                <input type="radio" name="isSign" value="1" th:field="${settings.isSign}">
                                <label>无需扫码签到</label>
                            </div>
                            <div class="radio-box">
                                <input type="radio" name="isSign" value="0" th:field="${settings.isSign}">
                                <label>指定人员登录系统后开启扫码页（推荐）</label>
                            </div>
                        </div>
                    </div>
                    <div>
                        <div class="col-sm-8" id="userForSignDiv">
                            <select id="userForSign" name="userForSign" class="form-control select2-hidden-accessible" multiple="">
                                <option th:each="user:${cookUsers}" th:value="${user.userId}" th:text="${user.userName + '（' + user.loginName + '）'}" th:selected="${user.flag}" th:disabled="${user.status == '1'}"></option>
                            </select>
                        </div>
                        <!--<div class="tips">登录网址： http://2t2381r099.imwork.net:46223/meals/scan/qrcode</div>-->
                    </div>
                </div>
            </div>

            <div class="line"></div>

            <div class="content04">
                <div class="top">
                    <div>
                        <label class="col-sm-3 control-label">客餐设置</label>
                        <div class="col-sm-9">
                            <div class="radio-box" th:each="dict : ${@dict.getType('guest_setting')}">
                                <input type="radio" th:id="${dict.dictCode}" name="guestSetting" th:value="${dict.dictValue}" th:field="${settings.guestSetting}">
                                <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                            </div>
                        </div>
                    </div>
                    <div>
                        <div class="col-sm-8" id="userForGuestDiv">
                            <select id="userForGuest" name="userForGuest" class="form-control select2-hidden-accessible" multiple="">
                                <option th:each="user:${guestUsers}" th:value="${user.userId}" th:text="${user.userName + '（' + user.loginName + '）'}" th:selected="${user.flag}" th:disabled="${user.status == '1'}"></option>
                            </select>
                        </div>
                    </div>

                </div>

                <div>
                    <label class="col-sm-3 control-label child1" for="-NaN">客餐报餐日期</label>
                    <div class="col-sm-9">
                        <div class="radio-box" th:each="dict : ${@dict.getType('guest_meals_date')}">
                            <input type="radio" th:id="${dict.dictCode}" name="guestDate" th:value="${dict.dictValue}" th:field="${settings.guestDate}">
                            <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                        </div>
                    </div>
                </div>

                <div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">报餐时间</label>
                        <label class="col-sm-3 label2">在就餐前</label>
                        <div class="col-sm-9">
                            <select id="guestTime" class="form-control m-b" th:with="type=${@dict.getType('meals_time')}">
                                <option th:each="dict : ${type}" name="guestTime" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="${settings.guestTime}"></option>
                            </select>
                        </div>
                        <label class="col-sm-3 control-label">小时截止报餐</label>
                    </div>
                </div>

            </div>

            <div class="line"></div>

            <div class="content04">
                <div class="top">
                    <div>
                        <label class="col-sm-3 control-label child1" for="-NaN">围餐设置</label>
                        <div class="col-sm-9">
                            <div class="radio-box" th:each="dict : ${@dict.getType('peri_setting')}">
                                <input type="radio" th:id="${dict.dictCode}" name="periSetting"  th:value="${dict.dictValue}" th:field="${settings.periSetting}" >
                                <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}" ></label>
                            </div>

                            <!-- <label class="radio-box" > <input type="radio" name="periSetting" value="0" /> 目录 </label>
                            <label class="radio-box" > <input type="radio" name="periSetting" value="1" /> 菜单 </label>
                            <label class="radio-box" > <input type="radio" name="periSetting" value="2" /> 按钮 </label> -->

                        </div>
                    </div>
                    <div>
                        <div class="col-sm-8" id="userForPeriDiv">
                            <select id="userForPeri" name="userForPeri" class="form-control select2-hidden-accessible" multiple="">
                                <option th:each="user:${periUsers}" th:value="${user.userId}" th:text="${user.userName + '（' + user.loginName + '）'}" th:selected="${user.flag}" th:disabled="${user.status == '1'}"></option>
                            </select>
                        </div>
                    </div>
                </div>

                <div>
                    <label class="col-sm-3 control-label child1" for="-NaN">围餐报餐日期</label>
                    <div class="col-sm-9">
                        <div class="radio-box" th:each="dict : ${@dict.getType('peri_meals_date')}">
                            <input type="radio" th:id="${dict.dictCode}" name="periDate" th:value="${dict.dictValue}" th:field="${settings.periDate}">
                            <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                        </div>
                    </div>
                </div>

                <div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">报餐时间</label>
                        <label class="col-sm-3 label2">在就餐前</label>
                        <div class="col-sm-9">
                            <select id="periTime" class="form-control m-b" th:with="type=${@dict.getType('meals_time')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="${settings.periTime}"></option>
                            </select>
                        </div>
                        <label class="col-sm-3 control-label">小时截止报餐</label>
                    </div>
                </div>

            </div>

            <div class="line"></div>

            <div class="content04">
                <div class="top">
                    <div>
                        <label class="col-sm-3 control-label child1" for="-NaN">管理员</label>
                        <div class="col-sm-9">（可登录电脑端并使用全部功能）</div>
                    </div>
                    <div>
                        <div class="col-sm-8" id="userForMealsDiv">
                            <select id="userForMeals" name="userForMeals" class="form-control select2-hidden-accessible" multiple="">
                                <option th:each="user:${mealsUsers}" th:value="${user.userId}" th:text="${user.userName + '（' + user.loginName + '）'}" th:selected="${user.flag}" th:disabled="${user.status == '1'}"></option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>

            <div>
                <div class="form-group">
                    <div class="footer">
                        <button type="submit" class="btn btn-primary" >保存</button>
                        <!--<button class="btn btn-primary" data-toggle="button" onclick="recovery()">恢复</button>-->
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script th:src="@{/js/jquery-ui-1.10.4.min.js}"></script>
<script th:src="@{/ajax/libs/iCheck/icheck.min.js}"></script>
<script th:src="@{/ajax/libs//datapicker/bootstrap-datepicker.js}"></script>
<script th:src="@{/ajax/libs/beautifyhtml/beautifyhtml.js}"></script>
<script>

    $(function() {
        //showUserSelect();

        /* $('input').on('ifChecked', function(event){
            var menuType = $(event.target).val();
            if (menuType == "0") {
                $("#userForPeriDiv").hide();
            } else if (menuType == "1") {
                $("#userForPeriDiv").hide();
            } else if (menuType == "2") {
                $("#userForPeriDiv").show();
            }
        });   */

        var sign = $('input[name="isSign"]:checked').val();
        signVisible(sign);

        var guest = $('input[name="guestSetting"]:checked').val();
        guestVisible(guest);

        var peri = $('input[name="periSetting"]:checked').val();
        periVisible(peri);

        $('input:radio[name=isSign]').on('ifChecked',
            function(event) {
                var sign = $(event.target).val();
                signVisible(sign);
            });

        $('input:radio[name=guestSetting]').on('ifChecked',
            function(event) {
                var guest = $(event.target).val();
                guestVisible(guest);
            });

        $('input:radio[name=periSetting]').on('ifChecked',
            function(event) {
                var peri = $(event.target).val();
                periVisible(peri);
            });
    });

    function signVisible(sign) {
        if (sign == "1") {
            $("#userForSignDiv").hide();
        } else if (sign == "0") {
            $("#userForSignDiv").show();
        }
    }

    function guestVisible(guest) {
        if (guest == "0") {
            $("#userForGuestDiv").hide();
        } else if (guest == "1") {
            $("#userForGuestDiv").hide();
        } else if (guest == "2") {
            $("#userForGuestDiv").show();
        }
    }

    function periVisible(peri) {
        if (peri == "0") {
            $("#userForPeriDiv").hide();
        } else if (peri == "1") {
            $("#userForPeriDiv").hide();
        } else if (peri == "2") {
            $("#userForPeriDiv").show();
        }
    }

    $("#form-meals-setting").validate({
        rules:{
        },
        submitHandler: function(form) {
            edit();
        }
    });

    function recovery(){
        var mealsId = $("input[name='mealsId']").val();

        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "order/setting/recovery",
            data : {
                "mealsId": mealsId,
                "settingType":1
            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                if(data.code != 0){
                    $.modal.alertError(data.msg);
                }else{
                    $.modal.msgSuccess(data.msg);
                    window.location.reload();
                }
            }
        });
    }
    showSumPrice('breakfastType', 'b');
    showSumPrice('lunchType', 'l');
    showSumPrice('dinnerType', 'd');
    showSumPrice('otherType', 'o');
    // typename 指的是radio name的值，postfix class 后缀拼接如check-wrapper-d
    function showSumPrice(typename, postfix) {
        var parentId = $('input:radio[name='+ typename +']:checked').val() || 0;
        switch (typename) {
            case 'breakfastType':
                $('.check-wrapper-b').eq(parentId).addClass('display-show').removeClass('display-hide');
                break
            case 'lunchType':
                $('.check-wrapper-l').eq(parentId).addClass('display-show').removeClass('display-hide');
                break

            case 'dinnerType':
                $('.check-wrapper-d').eq(parentId).addClass('display-show').removeClass('display-hide');
                break
            case 'otherType':
                $('.check-wrapper-o').eq(parentId).addClass('display-show').removeClass('display-hide');
                break
            default:
                break
        }

        $('input:radio[name='+ typename +']').on('ifChecked', function(event) {
            var thisIndex = $(this).val()
            // var radioElLists = $(this).parents('.content03').siblings('.check-wrapper-' + postfix).children($('input:radio'));
            // console.log('radioElLists', radioElLists)
            if (thisIndex == 0) {
                $(this).parents('.content03').siblings('.check-wrapper-' + postfix).eq(0).addClass('display-show').removeClass('display-hide');
                $(this).parents('.content03').siblings('.check-wrapper-' + postfix).eq(1).addClass('display-hide').removeClass('display-show');
            } else {
                $(this).parents('.content03').siblings('.check-wrapper-' + postfix).eq(1).addClass('display-show').removeClass('display-hide');
                $(this).parents('.content03').siblings('.check-wrapper-' + postfix).eq(0).addClass('display-hide').removeClass('display-show');

            }
        });

    };

    function getInputVal(type, type1, type2, inputId1, inputId2) {
        var pRadioEl = $("input:radio[name=" + type + "]");
        var type1Ele = $("input:radio[name=" + type1 + "]");
        var type2Ele = $("input:radio[name=" + type2 + "]");
        var inputVal = '';
        if (pRadioEl[0].checked) {
            if (type1Ele[0].checked) {
                inputVal = type1Ele[0].value;
            } else if (type1Ele[1].checked)  {
                inputVal = $('#' + inputId1).val();
                if (!inputVal || parseInt(inputVal) <= 0) {
                    $('#' + inputId2).attr({'required': true});
                } else {
                    $('#' + inputId2).attr({'required': false});
                }
            }
        } else {
            if (type2Ele[0].checked) {
                inputVal = type2Ele[0].value;
            } else if (type2Ele[1].checked)  {
                inputVal = $('#' + inputId2).val();
                if (!inputVal || parseInt(inputVal) <= 0) {
                    $('#' + inputId2).attr({'required': true})
                } else {
                    $('#' + inputId2).attr({'required': false})
                }
            } else if (type2Ele[2].checked) {
                inputVal = type2Ele[2].value;
            }
        }
        return inputVal;
    };
    // 控制必填输入框
    inputController('breakfastType1', 'breakfast-type1');
    inputController('breakfastType2', 'breakfast-type2');
    inputController('lunchType1', 'lunch-type1');
    inputController('lunchType2', 'lunch-type2');
    inputController('dinnerType1', 'dinner-type1');
    inputController('dinnerType2', 'dinner-type2');
    inputController('otherType1', 'other-type1');
    inputController('otherType2', 'other-type2');
    function inputController(typeN, inputId) {
        var typeRadioEle = $("input:radio[name=" + typeN + "]");
        if (typeRadioEle[1].checked) {
            $('#' + inputId).attr({'required': true});
        }
        $("input:radio[name=" + typeN +"]").on('ifChecked', function () {
            const value = $(this).val()
            if (value === '0' || value === '-1') {
                $('#' + inputId).attr({'required': false});
            } else {
                $('#' + inputId).attr({'required': true});
            }
        });
    };
    function edit() {
        var mealsId = $("input[name='mealsId']").val();
        var mealsDate = $("input[name='mealsDate']:checked").val();
        var mealsTime = $("#mealsTime option:selected").val();
        var isBreakfast = $("input[name='isBreakfast']").is(':checked') == true ? 0 : 1;
        var breakfastStart = $('#breakfastStart option:selected') .val();
        var breakfastEnd = $('#breakfastEnd option:selected') .val();
        var breakfastType = $("input[name='breakfastType']:checked") .val();
        // var breakfastType1 = $("input[name='breakfastType1']:checked") .val();
        var breakfastType1 = getInputVal('breakfastType', 'breakfastType1', 'breakfastType2', 'breakfast-type1', 'breakfast-type2');
        // var breakfastType2 = $("input[name='breakfastType2']:checked") .val();
        var isLunch = $("input[name='isLunch']").is(':checked') == true ? 0 : 1;
        var lunchStart = $('#lunchStart option:selected') .val();
        var lunchEnd = $('#lunchEnd option:selected') .val();
        var lunchType = $("input[name='lunchType']:checked") .val();
        // var lunchType1 = $("input[name='lunchType1']:checked") .val();
        var lunchType1 = getInputVal('lunchType', 'lunchType1', 'lunchType2', 'lunch-type1', 'lunch-type2');
        // var lunchType2 = $("input[name='lunchType2']:checked") .val();
        var isDinner = $("input[name='isDinner']").is(':checked') == true ? 0 : 1;
        var dinnerStart = $('#dinnerStart option:selected') .val();
        var dinnerEnd = $('#dinnerEnd option:selected') .val();
        var dinnerType = $("input[name='dinnerType']:checked") .val();
        // var dinnerType1 = $("input[name='dinnerType1']:checked") .val();
        var dinnerType1 = getInputVal('dinnerType', 'dinnerType1', 'dinnerType2', 'dinner-type1', 'dinner-type2');
        // var dinnerType2 = $("input[name='dinnerType2']:checked") .val();
        var isOther = $("input[name='isOther']").is(':checked') == true ? 0 : 1;
        var otherStart = $('#otherStart option:selected') .val();
        var otherEnd = $('#otherEnd option:selected') .val();
        var otherType = $("input[name='otherType']:checked").val();
        var otherType1 = getInputVal('otherType', 'otherType1', 'otherType2', 'other-type1', 'other-type2');
        // var otherType2 = $("input[name='otherType2']:checked") .val();
        var isDishPic = $("input[name='isDishPic']").is(':checked') == true ? 0 : 1;
        var isSign = $('input[name="isSign"]:checked').val();
        // var isSign = $("input[name='isSign']").is(':checked') == true ? 0 : 1;
        var qrcodePassword = $("input[name='qrcodePassword']").val();
        var guestSetting = $("input[name='guestSetting']:checked").val();
        var guestDate = $("input[name='guestDate']:checked").val();
        var guestTime = $('#guestTime option:selected') .val();
        var periSetting = $("input[name='periSetting']:checked").val();
        var periDate = $("input[name='periDate']:checked").val();
        var periTime = $('#periTime option:selected') .val();

        var guestUserIds = $.form.selectSelects("userForGuest");
        var periUserIds = $.form.selectSelects("userForPeri");
        var managerUserIds = $.form.selectSelects("userForMeals");
        var cookUserIds = $.form.selectSelects("userForSign");

        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "order/setting/edit",
            data : {
                "mealsId": mealsId,
                "mealsDate": mealsDate,
                "mealsTime": mealsTime,
                "isBreakfast": isBreakfast,
                "breakfastStart": breakfastStart,
                "breakfastEnd": breakfastEnd,
                "breakfastType": breakfastType,
                "breakfastType1": breakfastType1,
                "isLunch": isLunch,
                "lunchStart": lunchStart,
                "lunchEnd": lunchEnd,
                "lunchType": lunchType,
                "lunchType1": lunchType1,
                "isDinner": isDinner,
                "dinnerStart": dinnerStart,
                "dinnerEnd": dinnerEnd,
                "dinnerType": dinnerType,
                "dinnerType1": dinnerType1,
                "isOther": isOther,
                "otherStart": otherStart,
                "otherEnd": otherEnd,
                "otherType": otherType,
                "otherType1": otherType1,
                "isDishPic": isDishPic,
                "isSign": isSign,
                "qrcodePassword": qrcodePassword,
                "guestSetting": guestSetting,
                "guestDate": guestDate,
                "guestTime": guestTime,
                "periSetting": periSetting,
                "periDate": periDate,
                "periTime": periTime,
                "guestUserIds":guestUserIds,
                "periUserIds":periUserIds,
                "managerUserIds":managerUserIds,
                "cookUserIds":cookUserIds
            },
            async : false,
            error : function(request) {
                $.modal.alertError(request.msg);
            },
            success : function(data) {
                if(data.code != 0){
                    $.modal.alertError(data.msg);
                }else{
                    $.modal.msgSuccess(data.msg);
                }
            }
        });
    }
</script>
</body>
</html>
